
const { ccclass, property } = cc._decorator;

const regionUrl = {
    default: 'https://voice.baidu.com/act/newpneumonia/newpneumonia/?from=com.pogorockgams.ncov2019',
    henan: 'https://voice.baidu.com/act/newpneumonia/newpneumonia/?from=com.pogorockgams.ncov2019&city=%E6%B2%B3%E5%8D%97-%E6%B2%B3%E5%8D%97',
    hubei: 'https://voice.baidu.com/act/newpneumonia/newpneumonia/?from=com.pogorockgams.ncov2019&city=%E6%B9%96%E5%8C%97-%E6%B9%96%E5%8C%97'
}

@ccclass
export default class WebViewForRegion extends cc.Component {

    @property(cc.WebView)
    webView: cc.Label = null;

    getRegion() {
        if (cc.sys.isNative) {
            if (cc.sys.OS_ANDROID) {
                return jsb.reflection.callStaticMethod(
                    'org.cocos2dx.javascript.service.ShortcutService',
                    'getRegion',
                    '()Ljava/lang/String;'
                )
            }
        }
        return 'default';
    }

    start() {
        let region = this.getRegion();
        cc.log('region', region);
        this.webView.url = regionUrl[region];
    }
}
